const reportTable=document.querySelector('.reportTable')

reportTable.addEventListener('click', (e) => {
    if (e.target.classList.contains('showAllReasons')) {
        e.target.previousElementSibling.classList.toggle('displayBlock');
    }
    if (e.target.classList.contains('showBlogContent')) {
        e.target.nextElementSibling.classList.remove('hidden');
    }
    if (e.target.classList.contains('hiddenBlogContent')) {
        const parentBlogBox = e.target.closest('.reportBlogBox');
        if (parentBlogBox) {
            parentBlogBox.classList.add('hidden');
        }
    }
    if (e.target.classList.contains('passReport')) {
        let selectedRow = e.target.closest('tr');
        let articleId=selectedRow.cells[3].innerText;
        $.ajax({
            url:'/weibo/manager/passReport',
            data:{
                id:articleId
            },
            success: function (result) {
                showCustomAlert('封禁成功',true)
            },
            error: function (error) {
                showCustomAlert('封禁失败',false)
            },

        });
        setTimeout(() => {
            location.reload()
        }, 1000);
    } else if (e.target.classList.contains('rejectReport')) {
         let selectedRow = e.target.closest('tr');
         let articleId=selectedRow.cells[3].innerText;
        $.ajax({
            url:'/weibo/manager/notPassReport',
            data:{
                id:articleId
            },
            success: function (result) {
                showCustomAlert('驳回成功',true)
            },
            error: function (error) {
                showCustomAlert('驳回失败',false)
            },
        });
        setTimeout(() => {
            location.reload()
        }, 1000);
    }
})


